package com.ff.mapper;

import static com.ff.mapper.WaresDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import com.ff.model.Wares;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.insert.render.MultiRowInsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface WaresMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-06-15T17:32:43.3097905+08:00", comments="Source Table: wares")
    BasicColumn[] selectList = BasicColumn.columnList(wid, wname, recommendation, wprice, wphone, winventory, fsell);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-06-15T17:32:43.3048038+08:00", comments="Source Table: wares")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-06-15T17:32:43.3048038+08:00", comments="Source Table: wares")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-06-15T17:32:43.3048038+08:00", comments="Source Table: wares")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<Wares> insertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-06-15T17:32:43.3048038+08:00", comments="Source Table: wares")
    @InsertProvider(type=SqlProviderAdapter.class, method="insertMultiple")
    int insertMultiple(MultiRowInsertStatementProvider<Wares> multipleInsertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-06-15T17:32:43.3087929+08:00", comments="Source Table: wares")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("WaresResult")
    Optional<Wares> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-06-15T17:32:43.3097905+08:00", comments="Source Table: wares")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="WaresResult", value = {
        @Result(column="wid", property="wid", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="wname", property="wname", jdbcType=JdbcType.VARCHAR),
        @Result(column="recommendation", property="recommendation", jdbcType=JdbcType.VARCHAR),
        @Result(column="wprice", property="wprice", jdbcType=JdbcType.DOUBLE),
        @Result(column="wphone", property="wphone", jdbcType=JdbcType.VARCHAR),
        @Result(column="winventory", property="winventory", jdbcType=JdbcType.INTEGER),
        @Result(column="fsell", property="fsell", jdbcType=JdbcType.INTEGER)
    })
    List<Wares> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-06-15T17:32:43.3097905+08:00", comments="Source Table: wares")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-06-15T17:32:43.3097905+08:00", comments="Source Table: wares")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, wares, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-06-15T17:32:43.3097905+08:00", comments="Source Table: wares")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, wares, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-06-15T17:32:43.3097905+08:00", comments="Source Table: wares")
    default int deleteByPrimaryKey(Integer wid_) {
        return delete(c -> 
            c.where(wid, isEqualTo(wid_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-06-15T17:32:43.3097905+08:00", comments="Source Table: wares")
    default int insert(Wares record) {
        return MyBatis3Utils.insert(this::insert, record, wares, c ->
            c.map(wid).toProperty("wid")
            .map(wname).toProperty("wname")
            .map(recommendation).toProperty("recommendation")
            .map(wprice).toProperty("wprice")
            .map(wphone).toProperty("wphone")
            .map(winventory).toProperty("winventory")
            .map(fsell).toProperty("fsell")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-06-15T17:32:43.3097905+08:00", comments="Source Table: wares")
    default int insertMultiple(Collection<Wares> records) {
        return MyBatis3Utils.insertMultiple(this::insertMultiple, records, wares, c ->
            c.map(wid).toProperty("wid")
            .map(wname).toProperty("wname")
            .map(recommendation).toProperty("recommendation")
            .map(wprice).toProperty("wprice")
            .map(wphone).toProperty("wphone")
            .map(winventory).toProperty("winventory")
            .map(fsell).toProperty("fsell")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-06-15T17:32:43.3097905+08:00", comments="Source Table: wares")
    default int insertSelective(Wares record) {
        return MyBatis3Utils.insert(this::insert, record, wares, c ->
            c.map(wid).toPropertyWhenPresent("wid", record::getWid)
            .map(wname).toPropertyWhenPresent("wname", record::getWname)
            .map(recommendation).toPropertyWhenPresent("recommendation", record::getRecommendation)
            .map(wprice).toPropertyWhenPresent("wprice", record::getWprice)
            .map(wphone).toPropertyWhenPresent("wphone", record::getWphone)
            .map(winventory).toPropertyWhenPresent("winventory", record::getWinventory)
            .map(fsell).toPropertyWhenPresent("fsell", record::getFsell)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-06-15T17:32:43.3097905+08:00", comments="Source Table: wares")
    default Optional<Wares> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, wares, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-06-15T17:32:43.3097905+08:00", comments="Source Table: wares")
    default List<Wares> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, wares, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-06-15T17:32:43.3097905+08:00", comments="Source Table: wares")
    default List<Wares> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, wares, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-06-15T17:32:43.3097905+08:00", comments="Source Table: wares")
    default Optional<Wares> selectByPrimaryKey(Integer wid_) {
        return selectOne(c ->
            c.where(wid, isEqualTo(wid_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-06-15T17:32:43.3097905+08:00", comments="Source Table: wares")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, wares, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-06-15T17:32:43.3097905+08:00", comments="Source Table: wares")
    static UpdateDSL<UpdateModel> updateAllColumns(Wares record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(wid).equalTo(record::getWid)
                .set(wname).equalTo(record::getWname)
                .set(recommendation).equalTo(record::getRecommendation)
                .set(wprice).equalTo(record::getWprice)
                .set(wphone).equalTo(record::getWphone)
                .set(winventory).equalTo(record::getWinventory)
                .set(fsell).equalTo(record::getFsell);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-06-15T17:32:43.3097905+08:00", comments="Source Table: wares")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(Wares record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(wid).equalToWhenPresent(record::getWid)
                .set(wname).equalToWhenPresent(record::getWname)
                .set(recommendation).equalToWhenPresent(record::getRecommendation)
                .set(wprice).equalToWhenPresent(record::getWprice)
                .set(wphone).equalToWhenPresent(record::getWphone)
                .set(winventory).equalToWhenPresent(record::getWinventory)
                .set(fsell).equalToWhenPresent(record::getFsell);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-06-15T17:32:43.3097905+08:00", comments="Source Table: wares")
    default int updateByPrimaryKey(Wares record) {
        return update(c ->
            c.set(wname).equalTo(record::getWname)
            .set(recommendation).equalTo(record::getRecommendation)
            .set(wprice).equalTo(record::getWprice)
            .set(wphone).equalTo(record::getWphone)
            .set(winventory).equalTo(record::getWinventory)
            .set(fsell).equalTo(record::getFsell)
            .where(wid, isEqualTo(record::getWid))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2022-06-15T17:32:43.3097905+08:00", comments="Source Table: wares")
    default int updateByPrimaryKeySelective(Wares record) {
        return update(c ->
            c.set(wname).equalToWhenPresent(record::getWname)
            .set(recommendation).equalToWhenPresent(record::getRecommendation)
            .set(wprice).equalToWhenPresent(record::getWprice)
            .set(wphone).equalToWhenPresent(record::getWphone)
            .set(winventory).equalToWhenPresent(record::getWinventory)
            .set(fsell).equalToWhenPresent(record::getFsell)
            .where(wid, isEqualTo(record::getWid))
        );
    }
}